import requests
import re
def yanzheng():
    data = open('C:/Users/yehuo/PycharmProjects/proxy/a.txt')
    data = data.read()
    data = data.replace(']','')
    data = data.replace('[','')
    data = data.replace(' ','')
    data = data.replace('\'','')
    data = data.split(',')
    headers = {
            'User-Agent':'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36'
                   }
    url = 'http://ip.chinaz.com/'
    for i in data:
        proxy = {
            'http':i,
            'https':i,
        }
        print (proxy)
        try:
            html = requests.get(url,headers=headers,proxies = proxy)
            patten = re.compile('您来自：</span>(\d+\.\d+\.\d+\.\d+)')
            res = patten.findall(html.text)
            print (res)
            if res[0]!=[]:
                print('%s验证成功'%i)
            else:
                print('%s失效'%i)
        except:
            print ('失效%s'%i)
    return 0
